import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import React, { forwardRef, useImperativeHandle, useMemo, useRef, useState, } from "react";
import { getCpasAllTids, getCpasByCategory, getJudgmentSheetName, saveCpasDescList, } from "./DraftApi";
import { Popup, ScrollView, TextBox } from "devextreme-react";
// import { useModel } from 'umi';
import notify from "devextreme/ui/notify";
import Form, { Item } from "devextreme-react/form";
import AntTabs from "~/public/cpas-ui/components-ui/ant-components/AntTab";
import { DevPopup } from "~/public/cpas-ui";
import "./_style.less";
export const SettingFormPupopHB = forwardRef((props, ref) => {
    // const { initialState } = useModel('@@initialState');
    // const { dbname } = initialState?.curPart as API.CurPart;
    const { dbname } = props;
    const [visible, setVisible] = useState(false);
    const cpasTableObj = useRef({}); // tid
    const cpasTableOrigin = useRef(""); // 来源
    const refsForm_HBGS = useRef(null);
    const refsFormOne = useRef(null);
    const refsForm_HB = useRef(null);
    const refsForm_GS = useRef(null);
    const tipsEntryRef = useRef(null);
    const [formAllData_HBGS, setFormAllData_HBGS] = useState({
        formAllData: {
            fullName: "",
            isColumnNum: false,
            setTableCount: 1,
            isSetTwoTable: false,
        },
        headerTitleName: "",
        headerTitleRightName: "",
        headerTitleLeftName: "",
        sign_GS0: "",
        sign_GS1: "",
        sign_GS2: "",
    });
    const [formAllData_HB, setFormAllData_HB] = useState({
        formAllData: { fullName: "", isColumnNum: false },
        headerTitleName: "",
        headerTitleRightName: "",
        headerTitleLeftName: "",
        sign_GS0: "",
        sign_GS1: "",
        sign_GS2: "",
    });
    const [formAllData_GS, setFormAllData_GS] = useState({
        formAllData: { fullName: "", isColumnNum: false },
        headerTitleName: "",
        headerTitleRightName: "",
        headerTitleLeftName: "",
        sign_GS0: "",
        sign_GS1: "",
        sign_GS2: "",
    });
    const [activeKey, setActiveKey] = useState("1");
    const [isSetTwoTableOrigin, setIsSetTwoTableOrigin] = useState("1");
    const cpasFun = useRef(null); // tid
    const validationRules = {
        fullName: [{ type: "required", message: "必填项不可删除" }],
    };
    const [formAllDataOne, setFormAllDataOne] = useState({
        formAllData: {
            fullName: "",
            isColumnNum: false,
            setTableCount: 1,
            isSetTwoTable: false,
        },
        headerTitleName: "",
        headerTitleRightName: "",
        headerTitleLeftName: "",
        sign_GS0: "",
        sign_GS1: "",
        sign_GS2: "",
    });
    /*
    _HB  合并
    _GS  公司
    _HBGS 合并公司
    */
    const changeData_fun = (paramsType, objKey, objValue) => {
        if (paramsType === "_HBGS") {
            setFormAllData_HBGS((oldData) => {
                const newData = { ...oldData };
                newData[objKey] = objValue;
                return newData;
            });
        }
        else if (paramsType === "_HB") {
            setFormAllData_HB((oldData) => {
                const newData = { ...oldData };
                newData[objKey] = objValue;
                return newData;
            });
        }
        else if (paramsType === "_GS") {
            setFormAllData_GS((oldData) => {
                const newData = { ...oldData };
                newData[objKey] = objValue;
                return newData;
            });
        }
    };
    const getCpasSettingData = async (tempTid, paramsType) => {
        if (!paramsType)
            return;
        const resHeader = await getCpasByCategory({
            projectMergeDb: dbname,
            tid: [tempTid],
            category: "fsHeader" + paramsType,
        });
        const resSign = await getCpasByCategory({
            projectMergeDb: dbname,
            tid: [tempTid],
            category: "signRow" + paramsType,
        });
        const resAlias = await getCpasByCategory({
            projectMergeDb: dbname,
            tid: [tempTid],
            category: "aliasName" + paramsType,
        });
        let tempHeader = {};
        let tempSign = [];
        let tempalias = {};
        tempHeader = JSON.parse(resHeader?.data[0]?.describe ?? "{}");
        tempalias = JSON.parse(resAlias?.data[0]?.describe ?? "{}");
        changeData_fun(paramsType, "headerTitleRightName", tempHeader?.headerTitleRightText ?? "");
        changeData_fun(paramsType, "headerTitleLeftName", tempHeader?.headerTitleLeftText ?? "");
        if (paramsType === "_HBGS") {
            changeData_fun(paramsType, "formAllData", {
                fullName: tempalias?.sheetName ?? "",
                isColumnNum: tempalias?.isColumnNum ?? false,
                isSetTwoTable: tempalias?.setTableCount === 2,
            });
        }
        else {
            changeData_fun(paramsType, "formAllData", {
                fullName: tempalias?.sheetName ?? "",
                isColumnNum: tempalias?.isColumnNum ?? false,
            });
        }
        changeData_fun(paramsType, "headerTitleName", tempalias?.headerTitleText ?? cpasTableObj.current.capsTitleName);
        tempSign = JSON.parse(resSign.data[0]?.describe ?? "{}");
        changeData_fun(paramsType, "sign_GS0", tempSign[0]?.signName ?? "");
        changeData_fun(paramsType, "sign_GS1", tempSign[1]?.signName ?? "");
        changeData_fun(paramsType, "sign_GS2", tempSign[2]?.signName ?? "");
    };
    const changeData_funOne = (objKey, objValue) => {
        setFormAllDataOne((oldData) => {
            const newData = { ...oldData };
            newData[objKey] = objValue;
            return newData;
        });
    };
    const getCpasSettingDataOne = async (tempTid) => {
        const resHeader = await getCpasByCategory({
            projectMergeDb: dbname,
            tid: [tempTid],
            category: "fsHeader",
        });
        const resSign = await getCpasByCategory({
            projectMergeDb: dbname,
            tid: [tempTid],
            category: "signRow",
        });
        const resAlias = await getCpasByCategory({
            projectMergeDb: dbname,
            tid: [tempTid],
            category: "aliasName",
        });
        let tempHeader = {};
        let tempSign = [];
        let tempalias = {};
        tempHeader = JSON.parse(resHeader?.data[0]?.describe ?? "{}");
        tempalias = JSON.parse(resAlias?.data[0]?.describe ?? "{}");
        changeData_funOne("headerTitleRightName", tempHeader?.headerTitleRightText ?? "");
        changeData_funOne("headerTitleLeftName", tempHeader?.headerTitleLeftText ?? "");
        changeData_funOne("formAllData", {
            fullName: tempalias?.sheetName ?? "",
            isColumnNum: tempalias?.isColumnNum ?? false,
            isSetTwoTable: tempalias?.setTableCount === 2,
        });
        changeData_funOne("headerTitleName", tempalias?.headerTitleText ?? cpasTableObj.current.capsTitleName);
        tempSign = JSON.parse(resSign.data[0]?.describe ?? "{}");
        changeData_funOne("sign_GS0", tempSign[0]?.signName ?? "");
        changeData_funOne("sign_GS1", tempSign[1]?.signName ?? "");
        changeData_funOne("sign_GS2", tempSign[2]?.signName ?? "");
    };
    // 自定义方法
    useImperativeHandle(ref, () => ({
        showPupop: async (curCpasObj, pupopFun) => {
            cpasFun.current = pupopFun;
            cpasTableObj.current = curCpasObj;
            setIsSetTwoTableOrigin(curCpasObj.isSetTwoTableOrigin);
            setActiveKey("1");
            cpasTableOrigin.current = `${curCpasObj.capsOrigin}-`;
            if (curCpasObj.isSetTwoTableOrigin === "2") {
                await getCpasSettingData(curCpasObj.capsTid, "_HBGS");
                await getCpasSettingData(curCpasObj.capsTid, "_HB");
                await getCpasSettingData(curCpasObj.capsTid, "_GS");
            }
            else {
                await getCpasSettingDataOne(curCpasObj.capsTid);
            }
            setVisible(true);
        },
    }));
    const HBTabsClick = (r) => {
        setActiveKey(r);
    };
    const onCancel = (isOK = false) => {
        setVisible(false);
        cpasTableObj.current = {};
        cpasFun.current?.cancelCallback();
        if (isOK) {
            cpasFun.current?.okCallback();
        }
    };
    const getallTidsList = async () => {
        const res = await getCpasAllTids({
            projectMergeDb: dbname,
            originTableName: cpasTableOrigin.current,
            isAllTid: true,
        });
        if (res.success) {
            const resMap = res.data
                .map((item) => item?.tid)
                .filter((item) => item);
            return {
                resTid: resMap,
                resData: res.data,
            };
        }
        else {
            notify("获取AllTids列表失败!", "error", 2000);
        }
        return {
            resTid: [],
            resData: [],
        };
    };
    const onOk = async (isSaveAll) => {
        let tempSignRow = "signRow_HBGS";
        let tempFsHeader = "fsHeader_HBGS";
        let tempAliasName = "aliasName_HBGS";
        let tempSignRowA = "signRow_HB";
        let tempFsHeaderA = "fsHeader_HB";
        let tempAliasNameA = "aliasName_HB";
        let tempSignRowB = "signRow_GS";
        let tempFsHeaderB = "fsHeader_GS";
        let tempAliasNameB = "aliasName_GS";
        if (cpasTableObj.current.isSetTwoTableOrigin === "2") {
            tempSignRow = "signRow_HBGS";
            tempFsHeader = "fsHeader_HBGS";
            tempAliasName = "aliasName_HBGS";
        }
        else {
            tempSignRow = "signRow";
            tempFsHeader = "fsHeader";
            tempAliasName = "aliasName";
        }
        if (cpasTableObj.current.isSetTwoTableOrigin === "2") {
            if (refsForm_HBGS.current) {
                const devForm = refsForm_HBGS.current;
                const result = devForm.instance.validate();
                console.log(!result.isValid, "@@@ 返回具体的结果");
                if (!result.isValid)
                    return notify("一张表内的Sheet页签是必填项", "error", 2000);
            }
            if (refsForm_HB.current) {
                const devForm = refsForm_HB.current;
                const result = devForm.instance.validate();
                console.log(!result.isValid, "@@@ 返回具体的结果");
                if (!result.isValid)
                    return notify("两张表内的合并-Sheet页签是必填项", "error", 2000);
            }
            if (refsForm_GS.current) {
                const devForm = refsForm_GS.current;
                const result = devForm.instance.validate();
                console.log(!result.isValid, "@@@ 返回具体的结果");
                if (!result.isValid)
                    return notify("两张表内的公司-Sheet页签是必填项", "error", 2000);
            }
            if (formAllData_HB.formAllData.fullName ===
                formAllData_GS.formAllData.fullName) {
                return notify("两张表内的公司和合并-Sheet页签禁止相同", "error", 2000);
            }
        }
        else {
            if (refsFormOne.current) {
                const devForm = refsFormOne.current;
                const result = devForm.instance.validate();
                console.log(!result.isValid, "@@@ 返回具体的结果");
                if (!result.isValid)
                    return notify("一张表内的Sheet页签是必填项", "error", 2000);
            }
        }
        if (cpasTableObj.current.isSetTwoTableOrigin === "2") {
            const res1 = await getJudgmentSheetName({
                likeName: `${cpasTableObj.current.capsOrigin}-`,
                judgmentSheetName: formAllData_HBGS.formAllData.fullName,
                projectMergeDb: dbname,
                tid: cpasTableObj.current.capsTid,
                categoryType: "aliasName_HBGS",
            });
            if (res1.data !== "success") {
                return notify("一张表内的Sheet页签禁止和其他Sheet页签重名", "error", 2000);
            }
            const res2 = await getJudgmentSheetName({
                likeName: `${cpasTableObj.current.capsOrigin}-`,
                judgmentSheetName: formAllData_GS.formAllData.fullName,
                projectMergeDb: dbname,
                tid: cpasTableObj.current.capsTid,
                categoryType: "aliasName_GS",
            });
            if (res2.data !== "success") {
                return notify("两张表内的公司-Sheet页签禁止和其他Sheet页签重名", "error", 2000);
            }
            const res3 = await getJudgmentSheetName({
                likeName: `${cpasTableObj.current.capsOrigin}-`,
                judgmentSheetName: formAllData_HB.formAllData.fullName,
                projectMergeDb: dbname,
                tid: cpasTableObj.current.capsTid,
                categoryType: "aliasName_HB",
            });
            if (res3.data !== "success") {
                return notify("两张表内的合并-Sheet页签禁止和其他Sheet页签重名", "error", 2000);
            }
        }
        else {
            const res1 = await getJudgmentSheetName({
                likeName: `${cpasTableObj.current.capsOrigin}-`,
                judgmentSheetName: formAllDataOne.formAllData.fullName,
                projectMergeDb: dbname,
                tid: cpasTableObj.current.capsTid,
                categoryType: "aliasName",
            });
            if (res1.data !== "success") {
                return notify("一张表内的Sheet页签禁止和其他Sheet页签重名", "error", 2000);
            }
        }
        let signRowData = [];
        let fsHeaderData = [];
        let aliasNameData = [];
        let signRowDataA = [];
        let fsHeaderDataA = [];
        let aliasNameDataA = [];
        let signRowDataB = [];
        let fsHeaderDataB = [];
        let aliasNameDataB = [];
        let tempSetTableCount = 1;
        if (cpasTableObj.current.isSetTwoTableOrigin === "2") {
            tempSetTableCount = formAllData_HBGS.formAllData.isSetTwoTable ? 2 : 1;
        }
        else {
            tempSetTableCount = formAllDataOne.formAllData.isSetTwoTable ? 2 : 1;
        }
        let tempFormAllData_HBGS = [];
        let tempFormAllData_HB = [];
        let tempFormAllData_GS = [];
        if (cpasTableObj.current.isSetTwoTableOrigin === "2") {
            tempFormAllData_HBGS = [
                {
                    signID: 1,
                    signName: formAllData_HBGS.sign_GS0,
                },
                {
                    signID: 2,
                    signName: formAllData_HBGS.sign_GS1,
                },
                {
                    signID: 3,
                    signName: formAllData_HBGS.sign_GS2,
                },
            ];
            tempFormAllData_HB = [
                {
                    signID: 1,
                    signName: formAllData_HB.sign_GS0,
                },
                {
                    signID: 2,
                    signName: formAllData_HB.sign_GS1,
                },
                {
                    signID: 3,
                    signName: formAllData_HB.sign_GS2,
                },
            ];
            tempFormAllData_GS = [
                {
                    signID: 1,
                    signName: formAllData_GS.sign_GS0,
                },
                {
                    signID: 2,
                    signName: formAllData_GS.sign_GS1,
                },
                {
                    signID: 3,
                    signName: formAllData_GS.sign_GS2,
                },
            ];
        }
        else {
            tempFormAllData_HBGS = [
                {
                    signID: 1,
                    signName: formAllDataOne.sign_GS0,
                },
                {
                    signID: 2,
                    signName: formAllDataOne.sign_GS1,
                },
                {
                    signID: 3,
                    signName: formAllDataOne.sign_GS2,
                },
            ];
        }
        if (isSaveAll) {
            const allTidData = await getallTidsList();
            if (allTidData.resTid.length) {
                if (cpasTableObj.current.isSetTwoTableOrigin === "2") {
                    signRowData = allTidData.resTid.map((item) => {
                        return {
                            tid: item,
                            category: tempSignRow,
                            describe: JSON.stringify(tempFormAllData_HBGS),
                        };
                    });
                    fsHeaderData = allTidData.resTid.map((item) => {
                        return {
                            tid: item,
                            category: tempFsHeader,
                            describe: JSON.stringify({
                                headerTitleRightText: formAllData_HBGS.headerTitleRightName,
                                headerTitleLeftText: formAllData_HBGS.headerTitleLeftName,
                            }),
                        };
                    });
                    aliasNameData = [
                        {
                            tid: cpasTableObj.current.capsTid,
                            category: tempAliasName,
                            describe: JSON.stringify({
                                sheetName: formAllData_HBGS.formAllData.fullName,
                                headerTitleText: formAllData_HBGS.headerTitleName,
                                isColumnNum: formAllData_HBGS.formAllData.isColumnNum,
                                setTableCount: tempSetTableCount,
                            }),
                        },
                    ];
                    signRowDataA = allTidData.resTid.map((item) => {
                        return {
                            tid: item,
                            category: tempSignRowA,
                            describe: JSON.stringify(tempFormAllData_HB),
                        };
                    });
                    fsHeaderDataA = allTidData.resTid.map((item) => {
                        return {
                            tid: item,
                            category: tempFsHeaderA,
                            describe: JSON.stringify({
                                headerTitleRightText: formAllData_HB.headerTitleRightName,
                                headerTitleLeftText: formAllData_HB.headerTitleLeftName,
                            }),
                        };
                    });
                    aliasNameDataA = [
                        {
                            tid: cpasTableObj.current.capsTid,
                            category: tempAliasNameA,
                            describe: JSON.stringify({
                                sheetName: formAllData_HB.formAllData.fullName,
                                headerTitleText: formAllData_HB.headerTitleName,
                                isColumnNum: formAllData_HB.formAllData.isColumnNum,
                            }),
                        },
                    ];
                    signRowDataB = allTidData.resTid.map((item) => {
                        return {
                            tid: item,
                            category: tempSignRowB,
                            describe: JSON.stringify(tempFormAllData_GS),
                        };
                    });
                    fsHeaderDataB = allTidData.resTid.map((item) => {
                        return {
                            tid: item,
                            category: tempFsHeaderB,
                            describe: JSON.stringify({
                                headerTitleRightText: formAllData_GS.headerTitleRightName,
                                headerTitleLeftText: formAllData_GS.headerTitleLeftName,
                            }),
                        };
                    });
                    aliasNameDataB = [
                        {
                            tid: cpasTableObj.current.capsTid,
                            category: tempAliasNameB,
                            describe: JSON.stringify({
                                sheetName: formAllData_GS.formAllData.fullName,
                                headerTitleText: formAllData_GS.headerTitleName,
                                isColumnNum: formAllData_GS.formAllData.isColumnNum,
                            }),
                        },
                    ];
                }
                else {
                    signRowData = allTidData.resTid.map((item) => {
                        return {
                            tid: item,
                            category: tempSignRow,
                            describe: JSON.stringify(tempFormAllData_HBGS),
                        };
                    });
                    fsHeaderData = allTidData.resTid.map((item) => {
                        return {
                            tid: item,
                            category: tempFsHeader,
                            describe: JSON.stringify({
                                headerTitleRightText: formAllDataOne.headerTitleRightName,
                                headerTitleLeftText: formAllDataOne.headerTitleLeftName,
                            }),
                        };
                    });
                    aliasNameData = [
                        {
                            tid: cpasTableObj.current.capsTid,
                            category: tempAliasName,
                            describe: JSON.stringify({
                                sheetName: formAllDataOne.formAllData.fullName,
                                headerTitleText: formAllDataOne.headerTitleName,
                                isColumnNum: formAllDataOne.formAllData.isColumnNum,
                                setTableCount: tempSetTableCount,
                            }),
                        },
                    ];
                }
            }
            else {
                notify(`获取全部的Tid失败！`, "error", 2000);
                // setVisiblePopup(false);
                return;
            }
        }
        else {
            if (cpasTableObj.current.isSetTwoTableOrigin === "2") {
                signRowData = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempSignRow,
                        describe: JSON.stringify(tempFormAllData_HBGS),
                    },
                ];
                fsHeaderData = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempFsHeader,
                        describe: JSON.stringify({
                            headerTitleRightText: formAllData_HBGS.headerTitleRightName,
                            headerTitleLeftText: formAllData_HBGS.headerTitleLeftName,
                        }),
                    },
                ];
                aliasNameData = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempAliasName,
                        describe: JSON.stringify({
                            sheetName: formAllData_HBGS.formAllData.fullName,
                            headerTitleText: formAllData_HBGS.headerTitleName,
                            isColumnNum: formAllData_HBGS.formAllData.isColumnNum,
                            setTableCount: tempSetTableCount,
                        }),
                    },
                ];
                signRowDataA = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempSignRowA,
                        describe: JSON.stringify(tempFormAllData_HB),
                    },
                ];
                fsHeaderDataA = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempFsHeaderA,
                        describe: JSON.stringify({
                            headerTitleRightText: formAllData_HB.headerTitleRightName,
                            headerTitleLeftText: formAllData_HB.headerTitleLeftName,
                        }),
                    },
                ];
                aliasNameDataA = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempAliasNameA,
                        describe: JSON.stringify({
                            sheetName: formAllData_HB.formAllData.fullName,
                            headerTitleText: formAllData_HB.headerTitleName,
                            isColumnNum: formAllData_HB.formAllData.isColumnNum,
                        }),
                    },
                ];
                signRowDataB = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempSignRowB,
                        describe: JSON.stringify(tempFormAllData_GS),
                    },
                ];
                fsHeaderDataB = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempFsHeaderB,
                        describe: JSON.stringify({
                            headerTitleRightText: formAllData_GS.headerTitleRightName,
                            headerTitleLeftText: formAllData_GS.headerTitleLeftName,
                        }),
                    },
                ];
                aliasNameDataB = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempAliasNameB,
                        describe: JSON.stringify({
                            sheetName: formAllData_GS.formAllData.fullName,
                            headerTitleText: formAllData_GS.headerTitleName,
                            isColumnNum: formAllData_GS.formAllData.isColumnNum,
                        }),
                    },
                ];
            }
            else {
                signRowData = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempSignRow,
                        describe: JSON.stringify(tempFormAllData_HBGS),
                    },
                ];
                fsHeaderData = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempFsHeader,
                        describe: JSON.stringify({
                            headerTitleRightText: formAllDataOne.headerTitleRightName,
                            headerTitleLeftText: formAllDataOne.headerTitleLeftName,
                        }),
                    },
                ];
                aliasNameData = [
                    {
                        tid: cpasTableObj.current.capsTid,
                        category: tempAliasName,
                        describe: JSON.stringify({
                            sheetName: formAllDataOne.formAllData.fullName,
                            headerTitleText: formAllDataOne.headerTitleName,
                            isColumnNum: formAllDataOne.formAllData.isColumnNum,
                            setTableCount: tempSetTableCount,
                        }),
                    },
                ];
            }
        }
        let signRowCpasDesc = {
            projectMergeDb: dbname,
            cpasDesc: signRowData,
        };
        let fsHeaderCpasDesc = {
            projectMergeDb: dbname,
            cpasDesc: fsHeaderData,
        };
        let aliasNameCpasDesc = {
            projectMergeDb: dbname,
            cpasDesc: aliasNameData,
        };
        let signRowCpasDescA = {
            projectMergeDb: dbname,
            cpasDesc: signRowDataA,
        };
        let fsHeaderCpasDescA = {
            projectMergeDb: dbname,
            cpasDesc: fsHeaderDataA,
        };
        let aliasNameCpasDescA = {
            projectMergeDb: dbname,
            cpasDesc: aliasNameDataA,
        };
        let signRowCpasDescB = {
            projectMergeDb: dbname,
            cpasDesc: signRowDataB,
        };
        let fsHeaderCpasDescB = {
            projectMergeDb: dbname,
            cpasDesc: fsHeaderDataB,
        };
        let aliasNameCpasDescB = {
            projectMergeDb: dbname,
            cpasDesc: aliasNameDataB,
        };
        if (isSaveAll) {
            tipsEntryRef.current.show({
                title: "提示",
                okCallback: async () => {
                    if (cpasTableObj.current.isSetTwoTableOrigin === "2") {
                        await saveCpasDescList(aliasNameCpasDescB);
                        await saveCpasDescList(fsHeaderCpasDescB);
                        await saveCpasDescList(signRowCpasDescB);
                        await saveCpasDescList(aliasNameCpasDescA);
                        await saveCpasDescList(fsHeaderCpasDescA);
                        await saveCpasDescList(signRowCpasDescA);
                    }
                    await saveCpasDescList(aliasNameCpasDesc);
                    await saveCpasDescList(fsHeaderCpasDesc);
                    const res = await saveCpasDescList(signRowCpasDesc);
                    if (res.success) {
                        notify(`导出设置修改成功！`, "success", 2000);
                        onCancel(true);
                    }
                    else {
                        notify(`导出设置修改失败！`, "error", 2000);
                    }
                },
            });
        }
        else {
            if (cpasTableObj.current.isSetTwoTableOrigin === "2") {
                await saveCpasDescList(aliasNameCpasDescB);
                await saveCpasDescList(fsHeaderCpasDescB);
                await saveCpasDescList(signRowCpasDescB);
                await saveCpasDescList(aliasNameCpasDescA);
                await saveCpasDescList(fsHeaderCpasDescA);
                await saveCpasDescList(signRowCpasDescA);
            }
            await saveCpasDescList(aliasNameCpasDesc);
            await saveCpasDescList(fsHeaderCpasDesc);
            const res = await saveCpasDescList(signRowCpasDesc);
            if (res.success) {
                notify(`导出设置修改成功！`, "success", 2000);
                onCancel(true);
            }
            else {
                notify(`导出设置修改失败！`, "error", 2000);
            }
        }
    };
    const oneTable = (_jsx("div", { className: "settingTabsBoxHBOne", children: _jsx(ScrollView, { width: "100%", height: "100%", children: useMemo(() => {
                const { headerTitleName, headerTitleLeftName, headerTitleRightName, sign_GS0, sign_GS1, sign_GS2, formAllData, } = formAllDataOne;
                return (_jsxs("div", { className: "settingFormHB", style: { margin: "8px 0" }, children: [_jsxs("div", { style: {
                                paddingBottom: "8px",
                                borderBottom: "1px solid #ddd",
                            }, children: [_jsx("div", { className: "settingTitle", children: "\u6807\u9898\u884C\u8BBE\u8BA1" }), _jsxs("div", { className: "settingbiaoti settingNoneBorder", children: [_jsx(TextBox, { value: headerTitleName, defaultValue: "", width: 300, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                const { value } = e;
                                                changeData_funOne("headerTitleName", value);
                                            } }), _jsx("div", { style: {
                                                fontSize: "12px",
                                                color: "#929292",
                                                textAlign: "center",
                                            }, children: cpasTableObj.current.capsTitleDate })] }), _jsxs("div", { className: "settingTanx settingNoneBorder", children: [_jsx("div", { className: "settingTanxCenter settingTextLeft", children: _jsx(TextBox, { value: headerTitleLeftName, defaultValue: "", width: 230, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                    const { value } = e;
                                                    changeData_funOne("headerTitleLeftName", value);
                                                } }) }), _jsx("div", { className: "settingTextRight", children: _jsx(TextBox, { value: headerTitleRightName, defaultValue: "", width: 230, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                    const { value } = e;
                                                    changeData_funOne("headerTitleRightName", value);
                                                } }) })] })] }), _jsxs("div", { style: {
                                paddingBottom: "8px",
                                borderBottom: "1px solid #ddd",
                            }, children: [_jsx("div", { className: "settingTitle", children: "\u7B7E\u5B57\u884C\u8BBE\u8BA1" }), _jsxs("div", { className: "settingTanx settingNoneBorder", style: { flexWrap: "wrap" }, children: [_jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS0, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                const { value } = e;
                                                changeData_funOne("sign_GS0", value);
                                            } }), _jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS1, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                const { value } = e;
                                                changeData_funOne("sign_GS1", value);
                                            } }), _jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS2, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                const { value } = e;
                                                changeData_funOne("sign_GS2", value);
                                            } })] })] }), _jsxs("div", { children: [_jsx("div", { className: "settingTitle", children: "\u5176\u4ED6\u8BBE\u8BA1" }), _jsxs(Form, { ref: refsFormOne, formData: formAllData, colCount: 3, 
                                    // labelMode={"hidden"}
                                    // focusStateEnabled={true}
                                    showColonAfterLabel: true, alignItemLabels: true, children: [_jsx(Item, { dataField: "fullName", cssClass: "fullNameText", 
                                            //
                                            label: { text: "Sheet名称" }, validationRules: validationRules.fullName, editorOptions: {
                                                maxLength: 100,
                                                placeholder: "点击编辑内容",
                                            } }), _jsx(Item, { dataField: "isColumnNum", editorType: "dxCheckBox", label: { text: "是否配置栏次" } })] })] })] }));
            }, [formAllDataOne]) }) }));
    const twoTable = (_jsxs(AntTabs
    // activeKey={TbsStates.itemKey}
    // tabPosition={"right"}
    , { 
        // activeKey={TbsStates.itemKey}
        // tabPosition={"right"}
        className: "changeTabsHeightBox settingTabsBoxHB", tabBarStyle: { background: "#FFF" }, onChange: HBTabsClick, defaultActiveKey: "1", destroyInactiveTabPane: true, 
        // ref={tabsRef}
        activeKey: activeKey, children: [_jsx(AntTabs.Panel, { tab: "一张表", children: _jsx(ScrollView, { width: "100%", height: "100%", children: useMemo(() => {
                        const { headerTitleName, headerTitleLeftName, headerTitleRightName, sign_GS0, sign_GS1, sign_GS2, formAllData, } = formAllData_HBGS;
                        return (_jsxs("div", { className: "settingFormHB", style: { margin: "8px 0" }, children: [_jsxs("div", { style: {
                                        paddingBottom: "8px",
                                        borderBottom: "1px solid #ddd",
                                    }, children: [_jsx("div", { className: "settingTitle", children: "\u6807\u9898\u884C\u8BBE\u8BA1" }), _jsxs("div", { className: "settingbiaoti settingNoneBorder", children: [_jsx(TextBox, { value: headerTitleName, defaultValue: "", width: 300, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                        const { value } = e;
                                                        changeData_fun("_HBGS", "headerTitleName", value);
                                                    } }), _jsx("div", { style: {
                                                        fontSize: "12px",
                                                        color: "#929292",
                                                        textAlign: "center",
                                                    }, children: cpasTableObj.current.capsTitleDate })] }), _jsxs("div", { className: "settingTanx settingNoneBorder", children: [_jsx("div", { className: "settingTanxCenter settingTextLeft", children: _jsx(TextBox, { value: headerTitleLeftName, defaultValue: "", width: 230, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                            const { value } = e;
                                                            changeData_fun("_HBGS", "headerTitleLeftName", value);
                                                        } }) }), _jsx("div", { className: "settingTextRight", children: _jsx(TextBox, { value: headerTitleRightName, defaultValue: "", width: 230, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                            const { value } = e;
                                                            changeData_fun("_HBGS", "headerTitleRightName", value);
                                                        } }) })] })] }), _jsxs("div", { style: {
                                        paddingBottom: "8px",
                                        borderBottom: "1px solid #ddd",
                                    }, children: [_jsx("div", { className: "settingTitle", children: "\u7B7E\u5B57\u884C\u8BBE\u8BA1" }), _jsxs("div", { className: "settingTanx settingNoneBorder", style: { flexWrap: "wrap" }, children: [_jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS0, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                        const { value } = e;
                                                        changeData_fun("_HBGS", "sign_GS0", value);
                                                    } }), _jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS1, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                        const { value } = e;
                                                        changeData_fun("_HBGS", "sign_GS1", value);
                                                    } }), _jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS2, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                        const { value } = e;
                                                        changeData_fun("_HBGS", "sign_GS2", value);
                                                    } })] })] }), _jsxs("div", { children: [_jsx("div", { className: "settingTitle", children: "\u5176\u4ED6\u8BBE\u8BA1" }), _jsxs(Form, { ref: refsForm_HBGS, formData: formAllData, colCount: 3, 
                                            // labelMode={"hidden"}
                                            // focusStateEnabled={true}
                                            showColonAfterLabel: true, alignItemLabels: true, children: [_jsx(Item, { dataField: "fullName", cssClass: "fullNameText", 
                                                    //
                                                    label: { text: "Sheet名称" }, validationRules: validationRules.fullName, editorOptions: {
                                                        maxLength: 100,
                                                        placeholder: "点击编辑内容",
                                                    } }), _jsx(Item, { dataField: "isColumnNum", editorType: "dxCheckBox", label: { text: "是否配置栏次" } }), _jsx(Item, { dataField: "isSetTwoTable", editorType: "dxCheckBox", label: { text: "是否调两张表设置" } })] })] })] }));
                    }, [formAllData_HBGS]) }) }, "1"), _jsx(AntTabs.Panel, { tab: "两张表", children: _jsx(ScrollView, { width: "100%", height: "100%", children: _jsxs("div", { style: { margin: "8px 0" }, children: [useMemo(() => {
                                const { headerTitleName, headerTitleLeftName, headerTitleRightName, sign_GS0, sign_GS1, sign_GS2, formAllData, } = formAllData_HB;
                                return (_jsxs("div", { className: "settingFormHB", children: [_jsxs("div", { style: {
                                                paddingBottom: "8px",
                                                borderBottom: "1px solid #ddd",
                                            }, children: [_jsx("div", { className: "settingBoxTitle", children: "\u5408\u5E76" }), _jsx("div", { className: "settingTitle", children: "\u6807\u9898\u884C\u8BBE\u8BA1" }), _jsxs("div", { className: "settingbiaoti settingNoneBorder", children: [_jsx(TextBox, { value: headerTitleName, defaultValue: "", width: 300, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                const { value } = e;
                                                                changeData_fun("_HB", "headerTitleName", value);
                                                            } }), _jsx("div", { style: {
                                                                fontSize: "12px",
                                                                color: "#929292",
                                                                textAlign: "center",
                                                            }, children: cpasTableObj.current.capsTitleDate })] }), _jsxs("div", { className: "settingTanx settingNoneBorder", children: [_jsx("div", { className: "settingTanxCenter settingTextLeft", children: _jsx(TextBox, { value: headerTitleLeftName, defaultValue: "", width: 230, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                    const { value } = e;
                                                                    changeData_fun("_HB", "headerTitleLeftName", value);
                                                                } }) }), _jsx("div", { className: "settingTextRight", children: _jsx(TextBox, { value: headerTitleRightName, defaultValue: "", width: 230, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                    const { value } = e;
                                                                    changeData_fun("_HB", "headerTitleRightName", value);
                                                                } }) })] })] }), _jsxs("div", { style: {
                                                paddingBottom: "8px",
                                                borderBottom: "1px solid #ddd",
                                            }, children: [_jsx("div", { className: "settingTitle", children: "\u7B7E\u5B57\u884C\u8BBE\u8BA1" }), _jsxs("div", { className: "settingTanx settingNoneBorder", style: { flexWrap: "wrap" }, children: [_jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS0, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                const { value } = e;
                                                                changeData_fun("_HB", "sign_GS0", value);
                                                            } }), _jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS1, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                const { value } = e;
                                                                changeData_fun("_HB", "sign_GS1", value);
                                                            } }), _jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS2, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                const { value } = e;
                                                                changeData_fun("_HB", "sign_GS2", value);
                                                            } })] })] }), _jsxs("div", { children: [_jsx("div", { className: "settingTitle", children: "\u5176\u4ED6\u8BBE\u8BA1" }), _jsxs(Form, { ref: refsForm_HB, formData: formAllData, colCount: 2, 
                                                    // labelMode={"hidden"}
                                                    // focusStateEnabled={true}
                                                    showColonAfterLabel: true, alignItemLabels: true, children: [_jsx(Item, { dataField: "fullName", cssClass: "fullNameText", 
                                                            //
                                                            label: { text: "Sheet名称" }, validationRules: validationRules.fullName, editorOptions: {
                                                                maxLength: 100,
                                                                placeholder: "点击编辑内容",
                                                            } }), _jsx(Item, { dataField: "isColumnNum", editorType: "dxCheckBox", label: { text: "是否配置栏次" } })] })] })] }));
                            }, [formAllData_HB]), useMemo(() => {
                                const { headerTitleName, headerTitleLeftName, headerTitleRightName, sign_GS0, sign_GS1, sign_GS2, formAllData, } = formAllData_GS;
                                return (_jsxs("div", { className: "settingFormHB", children: [_jsxs("div", { style: {
                                                paddingBottom: "8px",
                                                borderBottom: "1px solid #ddd",
                                            }, children: [_jsx("div", { className: "settingBoxTitle", children: "\u516C\u53F8" }), _jsx("div", { className: "settingTitle", children: "\u6807\u9898\u884C\u8BBE\u8BA1" }), _jsxs("div", { className: "settingbiaoti settingNoneBorder", children: [_jsx(TextBox, { value: headerTitleName, defaultValue: "", width: 300, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                const { value } = e;
                                                                changeData_fun("_GS", "headerTitleName", value);
                                                            } }), _jsx("div", { style: {
                                                                fontSize: "12px",
                                                                color: "#929292",
                                                                textAlign: "center",
                                                            }, children: cpasTableObj.current.capsTitleDate })] }), _jsxs("div", { className: "settingTanx settingNoneBorder", children: [_jsx("div", { className: "settingTanxCenter settingTextLeft", children: _jsx(TextBox, { value: headerTitleLeftName, defaultValue: "", width: 230, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                    const { value } = e;
                                                                    changeData_fun("_GS", "headerTitleLeftName", value);
                                                                } }) }), _jsx("div", { className: "settingTextRight", children: _jsx(TextBox, { value: headerTitleRightName, defaultValue: "", width: 230, height: 32, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                    const { value } = e;
                                                                    changeData_fun("_GS", "headerTitleRightName", value);
                                                                } }) })] })] }), _jsxs("div", { style: {
                                                paddingBottom: "8px",
                                                borderBottom: "1px solid #ddd",
                                            }, children: [_jsx("div", { className: "settingTitle", children: "\u7B7E\u5B57\u884C\u8BBE\u8BA1" }), _jsxs("div", { className: "settingTanx settingNoneBorder", style: { flexWrap: "wrap" }, children: [_jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS0, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                const { value } = e;
                                                                changeData_fun("_GS", "sign_GS0", value);
                                                            } }), _jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS1, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                const { value } = e;
                                                                changeData_fun("_GS", "sign_GS1", value);
                                                            } }), _jsx(TextBox, { width: 230, height: 32, className: "settingTanxCenter settingTextLeft", defaultValue: "", value: sign_GS2, placeholder: "\u70B9\u51FB\u7F16\u8F91\u5185\u5BB9", valueChangeEvent: "keyup", onValueChanged: (e) => {
                                                                const { value } = e;
                                                                changeData_fun("_GS", "sign_GS2", value);
                                                            } })] })] }), _jsxs("div", { children: [_jsx("div", { className: "settingTitle", children: "\u5176\u4ED6\u8BBE\u8BA1" }), _jsxs(Form, { ref: refsForm_GS, formData: formAllData, colCount: 2, 
                                                    // labelMode={"hidden"}
                                                    // focusStateEnabled={true}
                                                    showColonAfterLabel: true, alignItemLabels: true, children: [_jsx(Item, { dataField: "fullName", cssClass: "fullNameText", 
                                                            //
                                                            label: { text: "Sheet名称" }, validationRules: validationRules.fullName, editorOptions: {
                                                                maxLength: 100,
                                                                placeholder: "点击编辑内容",
                                                            } }), _jsx(Item, { dataField: "isColumnNum", editorType: "dxCheckBox", label: { text: "是否配置栏次" } })] })] })] }));
                            }, [formAllData_GS])] }) }) }, "2")] }));
    return (_jsxs(_Fragment, { children: [_jsx(Popup, { visible: visible, title: `导出设计（${cpasTableObj.current.capsTabName}）`, width: 1000, height: activeKey === "1" ? "450px" : "80vh", onHiding: () => {
                    onCancel();
                }, toolbarItems: [
                    {
                        widget: "dxButton",
                        toolbar: "bottom",
                        location: "after",
                        options: {
                            text: "确定",
                            type: "default",
                            onClick: () => onOk(false),
                        },
                    },
                    {
                        widget: "dxButton",
                        toolbar: "bottom",
                        location: "after",
                        options: {
                            text: "应用全部",
                            width: 100,
                            type: "default",
                            onClick: () => onOk(true),
                        },
                    },
                    {
                        widget: "dxButton",
                        toolbar: "bottom",
                        location: "after",
                        options: {
                            text: "取消",
                            onClick: () => onCancel(),
                        },
                    },
                ], children: isSetTwoTableOrigin === "1" ? oneTable : twoTable }), _jsx(DevPopup.Default, { ref: tipsEntryRef, width: 180, height: 200, children: () => {
                    return (_jsx("span", { children: "\u8BE5\u64CD\u4F5C\u4E0D\u4FDD\u5B58\u6807\u9898\u5934\u3001\u680F\u6B21\u3001\u662F\u5426\u8C03\u4E24\u5F20\u8868\u8BBE\u7F6E\u548CSheet\u9875\u7B7E\u540D\u79F0\uFF0C\u786E\u5B9A\u8981\u6267\u884C\u6B64\u64CD\u4F5C\u5417\uFF1F" }));
                } })] }));
});
export default React.memo(SettingFormPupopHB);
